

<!-- 我的关注 -->
<template>
	<view class="container">
		
		<!-- header部分header-height -->
		<view class='header-Container header-height'>
			<view class="header-bg"></view>
			<navHeader pageTitle="我的关注" rightBtnType="msgCenter" colorTheme="black" @toggleMenuListHandler="toggleMenuListHandler">
			</navHeader>
		</view>
		
	
		<!-- 商品&店铺 -->
		<view class="navbar headerNext">
			<view 
				v-for="(item, index) in navList" :key="index" 
				class="nav-item" 
				:class="{current: tabCurrentIndex === index}"
				@click="categoryClick(index)"
			>
				{{item.name}}
			</view>
		</view>
		

		<!-- 关注列表 -->
		<view v-if="tabCurrentIndex == 0" class="favouriteList-Container">
			<goodListtransverse v-if="goodsList && goodsList.length" :list='goodsList'></goodListtransverse>
			<g-empty v-else></g-empty>
		</view>
		<view v-else class="favouriteList-Container">
			<view v-if="goodsList && goodsList.length">
				<view class="shop_block" v-for="item of goodsList" :key="item.vendorId" @click="toShop(item.vendorId)">
					<view class="shop_img flex-all-center">
						<image style="width: 160rpx;height: 160rpx; border-radius:20rpx;" :src="imgSite+item.logoUrl"></image>
					</view>
					<view class="shop_msg">
						<view class="shop_name">
							<view class="name ellipsis1">
								{{item.companyName}}
							</view>
<!--							<view class="tip" v-if="item.selfSupporting == '1'">自营</view>-->
						</view>
						<view class="shop_num">{{item.fllowNum}}人关注</view>
						<view v-if="item.newNum" class="newNum">
							{{item.newNum}}款上新
						</view>
						<view v-else class="newNum">
							未上新
						</view>
					</view>
					<image class="go" src="/static/images/user/baseInfo/moreBtn.png"></image>
				</view>
			</view>
			<g-empty v-else></g-empty>
		</view>
		
		
		<!-- 详情菜单 -->
		<view v-if="showDetailMenu" @click="toggleMenuListHandler()" class="detailMenu-Container">
			<detailMenu></detailMenu>
		</view>
	</view>
</template>

<script>
	import navHeader from '@/components/nav-header/nav-header';
	import detailMenu from "@/components/detailMenu/detailMenu";
	import goodListtransverse from '@/components/goodList/goodList-transverse';
	
	import {
	    mapState,  
	    mapMutations,
	} from 'vuex';  
	
	export default {
		components: {
			navHeader,
			detailMenu,
			goodListtransverse
		},
		data() {
			return {
				icon: {
				},
				
				//详情菜单
				showDetailMenu: false,
				
				//类型&关注列表
				tabCurrentIndex: 0,
				navList: [{
					type: "good",
					name: "商品"
				}, {
					type: "shop",
					name: "店铺"
				}],
				goodsList: [],
				
				//分页相关
				pageNum: 1,
				pageSize: 10
			};
		},
		computed:{
			...mapState(['hasLogin','imgSite']),
		},
		onLoad() {
			this.areaGoodsList();
		},
		onShow() {
			this.showDetailMenu = false;
		},
		methods: {
			
			//详情菜单
			toggleMenuListHandler() {
				console.log("详情菜单-我的关注");
				this.showDetailMenu = !this.showDetailMenu;
			},
			
			//分类点击
			categoryClick(index){
				this.tabCurrentIndex = index;
				this.goodsList = [];
				this.areaGoodsList();
			},
			
			//商品列表
			areaGoodsList() {
				
				var that = this;
				that.$api.globalUtil.requestAjax({
					url: '/customerAttentionApi/customerAttentionListApi',
					method: "POST",
					data: {
						caType: that.tabCurrentIndex,   //收藏类型 0商品、1商家
						pageNum: that.pageNum,  //页码
						pageSize: that.pageSize //显示条数
					},
					success: function(res) {
						if(res.data.success) {
							if(res.data.response.results.length == '0'){
								that.$api.msg("没有更多啦");
							}
							if(that.pageNum-0 == 1){
								that.goodsList = res.data.response.results;
							}else{
								for(let i of res.data.response.results){
									that.goodsList.push(i);
								}
							}
						}
					}
				});
			},
			toShop(id){
				uni.navigateTo({
					url: '/pagesGoods/shop/shopDetail?vendorId='+id
				});
			}
		},
		onPullDownRefresh() {
			var that = this;
			that.pageNum = 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.areaGoodsList();
		},
		onReachBottom() {
			var that = this;
			that.pageNum = that.pageNum + 1;
			
			setTimeout(function () {
				uni.stopPullDownRefresh();
			}, 1500);
			
			that.areaGoodsList();
		}
	}
</script>

<style lang="scss">

	page {
		background: #F5F5F5;
	}
	
	
	/* header部分 */
	.header-Container {
		z-index: 999;
		top: 0;
		width: 100%;
		height: 176rpx;
		overflow: hidden;
		box-shadow: 0px 1rpx 1rpx 0px rgba(0, 0, 0, 0.08);
		background: rgba(255, 255, 255, 1);
	
		.leftBtns {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
	
			.back {
				margin-left: 17rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	
		.title {
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
			line-height: 86rpx;
			text-align: center;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(51, 51, 51, 1);
		}
	}
	
	
	//商品&店铺
	.navbar {
		display: flex;
		z-index: 9;
		position: sticky;
		top: 86rpx;
		width: 100%;
		height: 80rpx;
		background: #fff;
		box-shadow: 0 1rpx 5rpx rgba(0,0,0,.06);
		
		.nav-item{
			flex: 1;
			display: flex;
			justify-content: center;
			align-items: center;
			position: relative;
			height: 100%;
			font-size:24rpx;
			font-family:PingFang;
			font-weight:500;
			color:rgba(51,51,51,1);
			
			&.current{
				font-weight:bold;
				color:rgba(51,51,51,1);
				&:after{
					content: '';
					position: absolute;
					left: 50%;
					bottom: 12rpx;
					transform: translateX(-50%);
					width: 50rpx;
					height: 4rpx;
					background:linear-gradient(135deg,rgba(209,2,168,1) 0%,rgba(210,23,40,1) 100%);
					border-radius:2px;
				}
			}
		}
		
		.moreCategory {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-left: auto;
			width: 80rpx;
			height: 80rpx;
			
			image {
				width: 21rpx;
				height: 12rpx;
			}
		}
	}
	
	
	//分割条
	.splitLineBar20rpx {
		z-index: 9;
		position: fixed;
		top: 256rpx;
		width: 100%;
		height: 20rpx;
		background: #F5F5F5;
	}
	
	
	//关注列表
	.favouriteList-Container {
		margin-top: 20rpx;
		width: 100%;
		background:rgba(255,255,255,1);
		border-radius:16rpx;
	}
	
	.shop_block{
		width: 100%;
		height: 248rpx;
		background-color: white;
		display: flex;
		position: relative;
		.shop_img{
			width: 217rpx;
			height: 100%;
		}
		.shop_msg {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			padding: 54rpx 0 52rpx 0;
			width: 533rpx;
			height: 100%;
			border-bottom: 1rpx solid #eee;
			
			.shop_name {
				display: flex;
				align-items: center;
				max-width: 500rpx;
				font-size: 32rpx;
				color: #333;
				
				.name {
					max-width: 420rpx;
				}
				
				.tip {
					background-color: #d21728;
					white-space: nowrap;
					color: white;
					border-radius: 3rpx;
					width: 57rpx;
					height: 30rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					font-size: 22rpx;
					margin-left: 16rpx;
				}
			}
			.shop_num {
				font-size: 24rpx;
				color: #333;
			}
			.newNum {
				width:118rpx;
				height:34rpx;
				line-height: 34rpx;
				text-align: center;
				font-size: 20rpx;
				color: #E01327;
				background:rgba(255,219,219,0.5);
				border-radius:17rpx;
			}
		}
		.go{
			width: 15rpx;
			height: 25rpx;
			position: absolute;
			top: 112rpx;
			right:32rpx;
		}
	}

	
</style>



